package org.restlesscode.javersion;

import java.io.IOException;

/**
 * Transcoders are used to convert Java Objects into Subversion objects.
 * Subversion objects can contain one content blob and multiple binary or
 * String properties. A transcoder will return a SvnObject on encode or
 * create the original object on decode.
 * @param <T>
 */
public interface Transcoder <T> {

    /**
     * Given a svnObject, create the original object.
     * @param svnObject Representation of data read from SVN.
     * @return the original java object stored
     * @throws IOException
     */
    public T decode(SvnObject svnObject) throws IOException;

    /**
     * Given a java object, convert it to a SvnObject to be stored
     * into a subversion repository. This involves identifying its
     * main content blob and properties and doing any serialization
     * necessary.
     * @param o java object to encode
     * @return Encoded representation of object, to be stored in SVN
     * @throws IOException
     */
    public SvnObject encode(T o) throws IOException;

}
